import request from "@/utils/request";

/**
 * 保存或修改表单字段数据
 * @param {*} data
 */
export function saveOrUpdate(data) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/formColum/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 查询分页数据
 * @param {*} params
 * @returns
 */
export function pages(params) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/formColum/pages",
    method: "get",
    params: params
  });
}

/**
 * 查询字段类型的数据集合
 * @returns
 */
export function getColumTypeList() {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/formColum/getColumTypeList",
    method: "get"
  });
}

/**
 * 根据ID修改状态
 * @param {*} id
 * @param {*} stateFlag
 * @returns
 */
export function tiggerState(id = "", stateFlag = "") {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/formColum/tiggerState",
    method: "get",
    params: {
      id,
      stateFlag
    }
  });
}

/**
 * 根据ID删除数据
 * @param {*} id
 */
export function deleteById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/formColum/deleteById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据ID查询数据
 * @param {*} id
 * @returns
 */
export function getById(id = "") {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/formColum/getById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据columChar查询是否存在
 * @param {*} columChar
 * @returns
 */
export function hasExistColumChar(columChar = "") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/formColum/hasExistColumChar/${columChar}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}
